﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;

namespace BusStopDataAccess
{
    internal class DistanceComparer : IComparer<BusStops>
    {
        public DistanceComparer(Point origin)
        {
            _origin = origin;
        }

        private Point _origin;

        private double distance(BusStops stop)
        {
            return MapUtil.Distance(_origin, new Point() { Lat = stop.Latitude, Lon = stop.Longitude });
        }
        public int Compare(BusStops x, BusStops y)
        {
            return distance(x).CompareTo(distance(y));
        }
    }
}
